<?
include "header.php";
$P = new cMyPage;
$P->loadHeader();
$P->loadTitle("Welcome");
$locList = array();
$loc['url'] = '/index.php';
$loc['name'] = 'Home';
array_push($locList, $loc);
$loc['url'] = '/members.php';
$loc['name'] = 'Members';
array_push($locList, $loc);
$P->loadLocation($locList);
$P->loadLinks();
$P->loadPreContent("Members");

if($P->isLoggedIn()) {

//Select users from db
$users = $db->sql_query("SELECT * FROM `phpbb_users` JOIN `users` on id = user_id");

//Count number of users items
$users_total = $db->sql_affectedrows();
?>
<table >
<thead>
<tr>
<td>Pic</td>
<td>Username</td>
<td>Location</td>
<td>Employer</td>
<td>Contact</td>
</tr>
</thead>
<tbody> 
<?
//Loop each user row 
while ($row = $db->sql_fetchrow($users)){

?>
<tr>
<td>
<img src="forum/download/file.php?avatar=<?=$row['user_avatar'];?>" border="0" /></td>
<td><a href="userinfo.php?uid=<?=$row['user_id']; ?>"><?=$row['name'] == NULL ? "Name Not Provided" : $row['name']; ?></a></td>
<td><?=$row['user_from']; ?></td>
<td><?=$row['e_name']; ?></td>
<td><?
$wMult = 1;

if( strlen($row['user_email']) > 0 ) 
	$wMult = strlen( $row['user_email'] );

$w = (int)7*$wMult;
$im = imagecreate($w, 30);

// White background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);

// Write the string at the top left
imagestring($im, 3, 0, 0, $row['user_email'], $textcolor);

// start buffering
ob_start();
// output jpeg (or any other chosen) format & quality
imagepng($im);
// capture output to string
$contents = ob_get_contents();
// end capture
ob_end_clean();

echo '<img src="data:image/png;base64,'. base64_encode($contents). '"/>';


?>
</td>
</tr>
<?
}
?>
</tbody>
</table>
      
<? //var_dump($user->data); ?>
<br /><br />
<? 
//Test RPI function
//if( $P->isRPI() ) echo "true"; else echo "false"; ?>
    
<? 

} // logged in if
else {

echo "Please log in.";
$P->displayLogin();
}

$P->loadPostContent(); $P->loadFooter(); ?>